import { aiService } from '@/utils/ai-service'

/**
 * 验证三个模型的配置是否正确
 */
export async function verifyAllModels() {
  console.log('🔍 验证模型配置...')
  
  // 检查配置
  const providers = aiService.getAvailableProviders()
  console.log('可用提供商:', providers.map(p => p.id))
  
  // 验证每个提供商的默认模型
  providers.forEach(provider => {
    console.log(`${provider.name}:`)
    console.log(`  - 默认模型: ${provider.defaultModel}`)
    console.log(`  - 可用模型: ${provider.models.map(m => m.id).join(', ')}`)
  })
  
  // 检查API密钥状态
  const status = aiService.getProviderStatus()
  console.log('\nAPI密钥状态:')
  Object.entries(status).forEach(([provider, info]) => {
    console.log(`- ${provider}: ${info.hasApiKey ? '✅ 已配置' : '❌ 未配置'}`)
  })
  
  // 快速测试三个模型
  console.log('\n🧪 快速验证测试:')
  
  const testModels = [
    { provider: 'qwen', model: 'qwen-plus-latest', name: '通义千问' },
    { provider: 'doubao', model: 'doubao-seed-1-6-250615', name: '豆包' },
    { provider: 'deepseek', model: 'deepseek-reasoner', name: 'DeepSeek' }
  ]
  
  for (const { provider, model, name } of testModels) {
    if (!status[provider as keyof typeof status].hasApiKey) {
      console.log(`⏭️ 跳过 ${name} - 未配置API密钥`)
      continue
    }
    
    try {
      console.log(`测试 ${name} (${model})...`)
      const response = await aiService.quickChat('你好', undefined, { provider, model })
      console.log(`✅ ${name} 工作正常: ${response.substring(0, 50)}...`)
    } catch (error) {
      console.log(`❌ ${name} 测试失败:`, error instanceof Error ? error.message : error)
    }
  }
  
  console.log('\n验证完成！')
}

// 如果直接运行此文件
if (typeof window === 'undefined') {
  verifyAllModels().catch(console.error)
}